import type { App } from 'vue'
import { createPinia } from 'pinia'

// 1、pinia的持久化插件
import { createPersistedState } from 'pinia-plugin-persistedstate'

const store = createPinia()

//2、 接收createPersistedState函数
const piniaPersistedState = createPersistedState()

// 3、在pinia中引入持久化插件
store.use(piniaPersistedState)

//全局注册 store
export function setupStore(app: App<Element>) {
  app.use(store)
}

export { store }